<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title></title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="robots" content="all,follow">
    <!-- Bootstrap CSS-->
    <link rel="stylesheet" href="static/vendor/bootstrap/css/bootstrap.min.css">
    <!-- Font Awesome CSS-->
    <link rel="stylesheet" href="static/vendor/font-awesome/css/font-awesome.min.css">
    <!-- Fontastic Custom icon font-->
    <link rel="stylesheet" href="static/css/fontastic.css">
    <!-- Google fonts - Poppins -->
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Poppins:300,400,700">
    <!-- theme stylesheet-->
    <link rel="stylesheet" href="static/css/style.default.css" id="theme-stylesheet">
    <!-- Custom stylesheet - for your changes-->
    <link rel="stylesheet" href="static/css/custom.css">
    <link rel="stylesheet" href="static/css/fileinput.css">
    <link rel="stylesheet" href="static/css/viewer.min.css">



    <!-- Favicon-->
    <link rel="shortcut icon" href="static/img/favicon.ico">
    <!-- Tweaks for older IEs-->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
        <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script><![endif]-->
</head>

<body>

    <div id="app">
        <div class="page">
            <!-- Main Navbar-->
            <header class="header">
                <nav class="navbar">
                    <!-- Search Box-->
                    <div class="search-box">
                        <button class="dismiss"><i class="icon-close"></i></button>
                        <form id="searchForm" action="#" role="search">
                            <input type="search" placeholder="What are you looking for..." class="form-control">
                        </form>
                    </div>
                    <div class="container-fluid">
                        <div class="navbar-holder d-flex align-items-center justify-content-between">
                            <!-- Navbar Header-->
                            <div class="navbar-header">
                                <!-- Navbar Brand -->
                                <a href="index.html" class="navbar-brand d-none d-sm-inline-block">
                                    <div class="brand-text d-none d-lg-inline-block"><span>淘书斋后台管理</span></div>
                            </div>
                            <!-- Navbar Menu -->
                            <ul class="nav-menu list-unstyled d-flex flex-md-row align-items-md-center">
                                <!-- Search-->
                                <li class="nav-item d-flex align-items-center">
                                    <a href="#"></a>
                                </li>

                                <!-- Logout    -->
                                <li class="nav-item">
                                    <li @click="logout()">
                                        <a href="#" class="nav-link logout"> <span class="d-none d-sm-inline">退出</span><i class="fa fa-sign-out"></i></a>
                                    </li>
                                </li>
                            </ul>
                        </div>
                    </div>
                </nav>
            </header>
            <div class="page-content d-flex align-items-stretch">
                <!-- Side Navbar -->
                <nav class="side-navbar">
                    <!-- Sidebar Header-->
                    <div class="sidebar-header d-flex align-items-center">
                        <div class="avatar"><img src="static/img/gao.jpg" alt="..." class="img-fluid rounded-circle"></div>
                        <div class="title">
                            <h1 class="h4">{{adminName}}</h1>
                            <p>管理员</p>
                        </div>
                    </div>
                    <!-- Sidebar Navidation Menus--><span class="heading">管理</span>
                    <ul class="list-unstyled">
                        <li>
                            <a href="index.html"> <i class="icon-home"></i>首页</a>
                        </li>
                        <li class="active">
                            <a href="#bookDownDropdown" aria-expanded="false" data-toggle="collapse"> <i class="icon-interface-windows"></i>书本管理</a>
                            <ul id="bookDownDropdown" class="collapse list-unstyled ">
                                <li><a href="book.html">书本列表</a></li>
                                <li><a href="booktype.html">书本类型列表</a></li>
                            </ul>
                        </li>

                        <li>
                            <a href="#orderDownDropdown" aria-expanded="false" data-toggle="collapse"> <i class="icon-interface-windows"></i>订单管理</a>
                            <ul id="orderDownDropdown" class="collapse list-unstyled ">
                                <li><a href="order.html">订单列表</a></li>
                            </ul>
                        </li>

                        <li>
                            <a href="#userDownDropdown" aria-expanded="false" data-toggle="collapse"> <i class="icon-interface-windows"></i>用户管理</a>
                            <ul id="userDownDropdown" class="collapse list-unstyled ">
                                <li><a href="user.html">用户列表</a></li>
                            </ul>
                        </li>


                    </ul><span class="heading">设置</span>
                    <ul class="list-unstyled">
                        <li>
                            <a href="role.html"> <i class="icon-flask"></i>权限管理 </a>
                        </li>
                    </ul>
                </nav>
                <div class="content-inner">
                    <!-- Page Header-->
                    <header class="page-header">
                        <div class="container-fluid">
                            <h2 class="no-margin-bottom">淘书斋</h2>
                        </div>
                    </header>
                    <!-- Breadcrumb-->
                    <div class="breadcrumb-holder container-fluid">
                        <ul class="breadcrumb">
                            <li class="breadcrumb-item"><a href="book.html">书本列表</a></li>
                            <li class="breadcrumb-item active">评价详情 </li>
                        </ul>
                    </div>
                    <!-- Forms Section-->

                    <section class="forms">
                        <div class="container-fluid">
                            <div class="row">

                                <!-- Form Elements -->
                                <div class="col-lg-12">
                                    <div class="card">
                                        <div class="card-close">
                                            <div class="dropdown">
                                                <button type="button" id="closeCard5" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="dropdown-toggle"><i class="fa fa-ellipsis-v"></i></button>

                                            </div>
                                        </div>
                                        <div class="card-header d-flex align-items-center">
                                            <h3 class="h4">评价详情</h3>
                                        </div>
                                        <div class="card-body" id="cardhtml">
                                            <form class="form-horizontal">
                                                <div class="daily-feeds card">


                                                    <div class="card-body no-padding">
                                                        <template v-for="(item,index) in evaluateList">
                                                        <div class="item clearfix">
                                                            <div class="feed d-flex justify-content-between">
                                                                <div class="feed-body d-flex justify-content-between">
                                                                    <a href="#" class="feed-profile"><img :src="item.userEvaluate.user.headImg" alt="person" class="img-fluid rounded-circle"></a>
                                                                    <div class="content">
                                                                        <h5>{{item.userEvaluate.user.nickName}}</h5>
                                                                        <div class="date">{{item.userEvaluate.evaluateTime}}</div>
                                                                    </div>
                                                                </div>

                                                            </div>
                                                            <div class="form-group row ">
                                                                <div class="col-md-1"></div>
                                                                <label class="form-control-label">{{item.userEvaluate.content}}</label>
                                                            </div>

                                                            <div class="form-group row ">
                                                                <div class="col-md-1"></div>
                                                                <div id="file" @click="imgPriview()">
                                                                    <template v-for="(item,index) in item.imgList">
                                                                    <image :src="item" width='170px' height='200px'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                                    </template>
                                                    </div>
                                                </div>
                                                <div v-if="item.reply.length>0" class="quote has-shadow">
                                                    <template v-for="(item,index) in item.reply"> 
                                                    <div v-if="item.adminId!=null">商家答复：{{item.content}} </div>
                                                    <!-- <div v-else>{{item.user.nickName}}：{{item.content}} </div> -->
 
                                                </template>
                                                </div>
                                                <div class="CTAs pull-right"><a class="btn btn-xs btn-danger" data-toggle="modal" data-target="#deleteModal" @click="deleteInfo(item.userEvaluate.evaluateId)"><i class="glyphicon glyphicon-trash"> </i>删除</a></div>
                                                <div class="CTAs pull-right"><a class="btn btn-xs btn-secondary" data-toggle="modal" data-target="#myModal" @click="reply(item.userEvaluate.evaluateId,item.userEvaluate.orderItemId)"><i class="glyphicon glyphicon-pencil"> </i>回复</a></div>
                                        </div>
                                        </template>

                                    </div>
                                </div>

                                </form>



                                <form class="form-inline">
                                    <div class="col-md-8"></div>

                                    <div id="page_nav">
                                        <nav aria-label="Page navigation">
                                            <ul class="pagination">
                                                <li @click="firstPage()"><a>首页</a></li>

                                                <li v-if="ifHasPrevious" @click="prePage()">
                                                    <a aria-label="Previous"> <span aria-hidden="true">&laquo;</span>
                                                    </a>
                                                </li>

                                                <li v-else class="disabled">
                                                    <a aria-label="Previous"> <span aria-hidden="true">&laquo;</span>
                                                    </a>
                                                </li>
                                                <template v-for="(item,index) in pageNums">
                                                            <li v-if="item==currentPage" class="active" @click="numPage(item, $event)"><a>{{item}}</a></li>
                                                            <li v-else @click="numPage(item, $event)"><a>{{item}}</a></li>
                                                        </template>
                                                <li v-if="ifHasNext" @click="nextPage()">
                                                    <a aria-label="Next"> <span aria-hidden="true">&raquo;</span>
                                                    </a>
                                                </li>

                                                <li v-else class="disabled">
                                                    <a aria-label="Next"> <span aria-hidden="true">&raquo;</span>
                                                    </a>
                                                </li>
                                                <li @click="lastPage()"><a>尾页</a></li>
                                            </ul>
                                        </nav>
                                    </div>
                                </form>


                                <div class="form-group row ">
                                    <div class="col-md-11"></div>

                                    <button type="button" @click="back()" class="btn btn-secondary "></a>返回</button>

                                </div>



                            </div>
                        </div>
                </div>
            </div>
        </div>
        </section>

        <!-- Modal-->
        <div id="myModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true" class="modal fade text-left">
            <div role="document" class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 id="exampleModalLabel" class="modal-title">答复</h4>
                        <button type="button" data-dismiss="modal" aria-label="Close" class="close"><span aria-hidden="true">×</span></button>
                    </div>
                    <div class="card-body">
                        <form class="form-horizontal">
                            <div v-if="DetailValid==='0'" class="form-group row">
                                <div class="col-sm-9 ">
                                    <textarea v-model="evaluate.content" class="form-control" @change="DetailChange()" rows="6"></textarea>
                                    <small class="help-block-none ">请输入答复</small>
                                </div>
                            </div>

                            <div v-else-if="DetailValid==='1'" class="form-group row has-success">
                                <div class="col-sm-9 ">
                                    <textarea v-model="evaluate.content" class="form-control is-valid" @change="DetailChange()" rows="6"></textarea>
                                </div>
                            </div>

                            <div v-else class="form-group row has-danger">
                                <div class="col-sm-9 ">
                                    <textarea v-model="evaluate.content" class="form-control is-invalid" @change="DetailChange()" rows="6"></textarea>
                                    <small class="help-block-none ">请输入答复</small>
                                </div>
                            </div>
                        </form>


                    </div>
                    <div class="modal-footer">
                        <button type="button" data-dismiss="modal" class="btn btn-secondary">取消</button>
                        <button type="button" class="btn btn-primary" @click="addEvaluate()">确认</button>
                    </div>
                </div>
            </div>
        </div>

        <!-- Modal-->
        <div id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true" class="modal fade text-left">
            <div role="document" class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 id="exampleModalLabel" class="modal-title">确认删除该评论？</h4>
                        <button type="button" data-dismiss="modal" aria-label="Close" class="close"><span aria-hidden="true">×</span></button>
                    </div>
                    <div class="modal-footer">
                        <button type="button" data-dismiss="modal" class="btn btn-secondary">取消</button>
                        <button type="button" class="btn btn-primary" @click="deleteEvaluate()">确认</button>
                    </div>
                </div>
            </div>
        </div>


        <!-- Page Footer-->
        <footer class="main-footer ">
            <div class="container-fluid ">
                <div class="row ">
                    <div class="col-sm-6 ">
                        <p class="weui-footer__text">Copyright © 2019 <a style="color:#3f8b81" href="#">抓娃小组</a>&nbsp版权所有</p>
                    </div>
                    <div class="col-sm-6 text-right ">
                        <p></p>
                        <!-- Please do not remove the backlink to us unless you support further theme's development at https://bootstrapious.com/donate. It is part of the license conditions. Thank you for understanding :)-->
                    </div>
                </div>
            </div>
        </footer>
    </div>
    </div>
    </div>

    </div>





    <!-- JavaScript files-->
    <script src="static/vendor/jquery/jquery.min.js "></script>
    <script src="static/vendor/popper.js/umd/popper.min.js ">
    </script>
    <script src="static/vendor/bootstrap/js/bootstrap.min.js "></script>
    <script src="static/vendor/jquery.cookie/jquery.cookie.js ">
    </script>
    <script src="static/vendor/chart.js/Chart.min.js "></script>
    <script src="static/vendor/jquery-validation/jquery.validate.min.js "></script>
    <!-- Main File-->
    <script src="static/js/front.js "></script>
    <script src="static/js/fileinput.js "></script>
    <script src="https://cdn.bootcss.com/bootstrap-fileinput/4.3.5/js/locales/zh.min.js "></script>
    <script src="static/js/viewer-jquery.min.js "></script>
    <script src="static/js/viewer.min.js"></script>
    <script src="static/node_modules/vue/dist/vue.js"></script>


    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                adminName: '',
                //服务器:http://47.100.136.219
                serverIp: 'http://47.100.136.219',
                ifLocal: false,
                evaluateList: [],
                bookId: '',
                pageNums: [],
                currentPage: 0,
                pageCount: 0,
                ifHasPrevious: false,
                ifHasNext: true,
                DetailValid: '0',
                ifHyperAdmin: 0,
                evaluate: {
                    adminId: null,
                    content: null,
                    evaluateId: null,
                    evaluateTime: null,
                    goodsGrade: null,
                    ifAnonymous: null,
                    img: null,
                    logisticsGrade: null,
                    orderItem: null,
                    orderItemId: null,
                    serviceGrade: null,
                    toEvaluateId: null,
                    user: null,
                    userId: null
                },
                evaluateSubmit: {
                    evaluate: {},
                    ifHyperAdmin: 0
                },
                deleteId: -1

            },
            mounted() {
                let _this = this;

                if (this.ifLocal) {
                    this.serverIp = "http://localhost";
                }


                $.ajax({
                    type: "GET",
                    url: _this.serverIp + ":8088/boot/admincommon/info",
                    success: function(response) {
                        if (response.code == 200) {
                            console.log(response.data);
                            _this.adminName = response.data.data.principal.username
                            if (response.data.data.authorities.length > 1) {
                                _this.ifHyperAdmin = 1;
                            } else {
                                _this.ifHyperAdmin = 0;
                            }
                        }
                    },

                });
                console.log(_this.ifHyperAdmin);

                _this.bookId = getQueryString("id");
                _this.createEvaluateList();

            },
            methods: {

                createEvaluateList() {
                    let _this = this;
                    $.ajax({
                        type: "GET",
                        url: _this.serverIp + ":8088/boot/adminbook/evaluate?pageIndex=" + _this.currentPage + "&id=" + _this.bookId,
                        success: function(response) {
                            if (response.code == 200) {
                                console.log(response.data);
                                _this.evaluateList = response.data.list.list;
                                _this.pageNums = response.data.list.navigatepageNums;
                                _this.pageCount = response.data.list.pages;

                            }
                        },
                        error: function(response) {

                            $("#cardhtml").replaceWith('<div class="card-close"></div><div class="card-header d-flex align-items-center"><h3 class="h4">不好意思，您不是书本管理员，无权访问</h3></div>');


                        }
                    });
                },
                addEvaluate() {
                    let _this = this;
                    _this.evaluateSubmit.evaluate = _this.evaluate;
                    _this.evaluateSubmit.ifHyperAdmin = _this.ifHyperAdmin;
                    console.log(_this.evaluateSubmit);
                    $.ajax({
                        type: "POST",
                        url: _this.serverIp + ":8088/boot/adminbook/evaluate",
                        data: JSON.stringify(_this.evaluateSubmit),
                        dataType: "json",
                        contentType: "application/json",
                        success: function(response) {
                            if (response.code == 200) {
                                console.log(response.data);
                                $('#myModal').modal('hide');
                                _this.createEvaluateList();
                            } else {
                                alert(response.msg);

                            }
                        }
                    });
                },

                reply(evaluateId, orderItemId) {
                    this.evaluate.toEvaluateId = evaluateId;
                    this.evaluate.orderItemId = orderItemId;
                    console.log(this.evaluate);
                },

                deleteInfo(id) {
                    this.deleteId = id;
                },

                deleteEvaluate() {
                    let _this = this;
                    console.log(_this.deleteId);
                    $.ajax({
                        type: "DELETE",
                        url: _this.serverIp + ":8088/boot/adminbook/evaluate/" + _this.deleteId,
                        success: function(response) {
                            if (response.code == 200) {
                                console.log(response.data);
                                $('#deleteModal').modal('hide');
                                _this.createEvaluateList();
                            } else {
                                alert(response.msg);

                            }
                        }
                    });
                },

                logout() {
                    let _this = this;
                    $.ajax({
                        url: _this.serverIP + ':8088/boot/logout',
                        type: 'POST',
                        success: function(res, status) {
                            console.log(res);
                            location.href = "login.html";

                        },
                        error: function(res, status) {
                            console.log(res);
                        }
                    });
                },
                coverPriview() {
                    $('#cover').viewer();
                },
                imgPriview() {
                    $('#file').viewer();
                },
                back() {
                    location.href =
                        "book-detail.html?id=" + this.bookId;
                },
                prePage() {

                    this.currentPage = this.currentPage - 1;

                    this.createBookList();
                },
                nextPage() {
                    this.currentPage = this.currentPage + 1;
                    this.createBookList();
                },

                firstPage() {

                    this.currentPage = 1;
                    this.createBookList();
                },
                lastPage() {

                    this.currentPage = this.pageCount;
                    this.createBookList();

                },


                numPage: function(num, event) {
                    if (this.curpage == num) {
                        return;
                    }

                    this.currentPage = num;
                    this.createBookList();

                },
                DetailChange() {
                    let _this = this;

                    if (_this.evaluate.content == "") {
                        _this.DetailValid = "-1";
                    } else {
                        _this.DetailValid = "1";
                    }
                },
            },
        });

        function getQueryString(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]);
            return null;
        }
    </script>




</body>

</html>